<template>
  <div>
    <el-button v-if="isShow" type="danger">{{ text }}</el-button>
    <el-button type="primary" @click="showBtn">点击我调用接口生成按钮</el-button>
    <el-button type="warning" @click="toVue2">跳转Vue2写法</el-button>
  </div>
</template>

<script>
import { getHelloWorld } from '@/api/index'
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
export default {
  name: 'helloworld',
  setup(props, ctx) {
    const text = ref('')
    const isShow = ref(false)
    const router = useRouter()
    const showBtn = async () => {
      const res = await getHelloWorld()
      text.value = res.name
      isShow.value = true
    }

    const toVue2 = () => {
      router.push({
        path: '/vue2'
      })
    }

    return {
      text,
      isShow,
      showBtn,
      toVue2
    }
  }
}
</script>

<style lang="scss" scoped></style>
